import { PullToRefresh, Toast } from 'antd-mobile';
import React, { Component } from 'react'
import { withRouter } from 'react-router-dom';
import { qutebus } from '../../redux/actionCreator';
import { connect } from 'react-redux'
import './setup.css'
import { Loginout_tim } from '../../TIM/actiontim';
import { imgInter } from '../../data/Interface';
// import { HashRouter as Router, Route, NavLink, Switch, Redirect, Link } from 'react-router-dom';


class Setup_bus extends Component {
    constructor() {
        super()
        this.state = {
            cacheSize: ''
        }
        // let self = this;
    }

    // shelf=this;
    // async getCachesize(){
    //     const data = await CacheManager.getCachesize();
    //     const size = data/(1024*1024);
    //     this.setState({cacheSize:`${size.toFixed(2)}M`})
    // }
    // async clearCacheSize(){
    //     await CacheManager.clearCacheSize();
    //     //这里好像不能全部清除成0，直接写死成0
    //     this.setState({cacheSize:'0.00M'});
    //     Toast.info('清除缓存成功')
    // }
    render() {
        // void plus.cache.clear( ()=>{console.log()} );
        // console.log(this.cacheSize)
        let src = localStorage.getItem('identity') == 'shop' ? JSON.parse(localStorage.getItem('user')).business_pic : JSON.parse(localStorage.getItem('user')).user_pic
        return (
            <div style={{ minHeight: '100vh', display: 'flex' }}>
                <div style={{ backgroundColor: "#080904", minHeight: '100vh', display: 'flex', width: '100%' }}>
                    <div style={{ width: '90%', margin: '0 auto' }}>
                        <div style={{ height: '20px' }}></div>
                        <i className="iconfont icon-fanhui" style={{ fontSize: '1.7em' }} onClick={() => this.props.history.goBack()}></i>
                        <div style={{ fontSize: '1.5em', fontWeight: 'bold', paddingTop: '25px', paddingBottom: '20px' }}>设置</div>

                        {/* 下方的小列表 */}
                        <div style={{ width: '90%', margin: '0 auto' }}>

                            {/* 进行一些基本信息的修改 */}
                            <div
                                onClick={() => { this.props.history.push('/accountmanbus') }}
                                className="setup-list">
                                <span>账户管理</span>
                                <img
                                    style={{ position: 'absolute', right: '3.3em', height: '1.8em', width: '1.8em', borderRadius: '50%', border: '1px solid white' }}
                                    src={`${imgInter}` + src}
                                ></img>
                            </div>

                            {/* 进行账号手机号和邮箱的绑定 */}
                            <div
                                onClick={() => { this.props.history.push('/accountsafebus') }}
                                className="setup-list">
                                <span>修改密码</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div>

                            {/* 这两个功能不确定要写，有空再写 */}
                            {/* <div className="setup-list">
                                <span>隐私设置</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div> */}

                            {/* <div className="setup-list">
                                <span>通知设置</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div> */}

                            <div
                                onClick={() => { this.props.history.push('/accountbindbus') }}
                                className="setup-list">
                                <span>修改绑定</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div>

                            <div
                                onClick={() => { this.props.history.push('/feedbackbus') }}
                                className="setup-list">
                                <span>我要反馈</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div>
                            <div
                                onClick={() => { this.props.history.push('/accountwhibus') }}//换一下
                                className="setup-list">
                                <span>实名认证</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div>
                            <div
                                onClick={() => { this.props.history.push('/accountpaybus') }}//换一下
                                className="setup-list">
                                <span>支付方式</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div>
                            <div
                                onClick={() => { this.props.history.push('/accountdesbus') }}//换一下
                                className="setup-list">
                                <span>商家描述</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div>
                            <div
                                onClick={() => {
                                    this.props.history.push({
                                        pathname: '/kefu',
                                        search: 'business_id=10'
                                    })
                                }}
                                className="setup-list">
                                <span>联系客服</span>
                                <i className="iconfont icon-qianjin"></i>
                            </div>

                            <div className="setup-list">
                                <span>清理缓存</span>
                                {/* <i className="iconfont icon-qianjin"></i> */}
                            </div>

                            {/* 退出登录 */}
                            <div
                                className='setup-outlog'
                                onClick={() => {
                                    this.props.dispatch(qutebus(JSON.parse(localStorage.getItem('user')).business_id))
                                    this.props.history.push('/first')
                                    Loginout_tim()
                                }}
                            >退出登录</div>


                        </div>

                    </div>
                </div>
                <div style={{ flex: '1' }}></div>
            </div>
        )
    }
}

const mapStateToProps = (state) => (
    {
        login: state.login
    }
)

export default withRouter(connect(mapStateToProps)(Setup_bus))
